﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mono.Cecil;
using System.IO;
using cilada.engine.Graph;

namespace cilada.engine
{
    public static class TypeUtilities
    {
        public static bool TryResolveTypeReference(this TypeReference typeRef, out TypeDefinition resolvedTypeDefinition)
        {
            try
            {
                resolvedTypeDefinition = typeRef.Resolve();

                if (resolvedTypeDefinition == null)
                {
                    return false;
                }

                return true;
            }
            catch (FileNotFoundException fnfe)
            {
                // log error somewhere
            }
            catch (Exception e)
            {
                // log error somewhere
            }

            resolvedTypeDefinition = null;
            return false;
        }
    }
}
